class Animal:
    def speak(self):
        print("我是动物我会说话")
class People(Animal):
    def speak(self):
        print("say hello")
class Dog(Animal):
    def speak(self):
        print("汪汪汪")
class Pig(Animal):
    def speak(self):
        print("哼哼哼")
class Duck(Animal):
    def speak(self):
        print("嘎嘎嘎")


# 三个对象都是动物
obj1 = People()
obj2 = Dog()
obj3 = Pig()
obj4 = Duck()

# obj1.speak()
# obj2.speak()
# obj3.speak()
# 既然他们都有一个同名的方法，那是否可以封装一个统一的方法去调用，减少代码冗余
def speakApi(obj):
    # 谁传入进来，谁说话
    obj.speak()
speakApi(obj1)
speakApi(obj2)
speakApi(obj4)



